* Apply to: roadmaps_1.dta
* Description:  Table A7 in the OA

clear

set more off


use "...\1805 Roadmaps\roadmaps_1.dta", clear


* Treatment variables

gen con = 0
replace con = 1 if ctr_marlee!=.

gen vgd = 0
replace vgd = 1 if vgd_marlee!=.

gen pty = 0
replace pty = 1 if pty_marlee!=.

gen psi = 0
replace psi = 1 if psi_marlee!=.

gen psp = 0
replace psp = 1 if psp_marlee!=.

gen an3 = 0
replace an3 = 1 if end_marlee!=.
replace an3 = 1 if end_ideo_marlee!=.


gen all_info = 0
replace all_info = 1 if (vgd==1 | pty==1 | psi==1 | psp==1)


* Drop extraneous respondents

drop if an3==1
drop if party=="Republican"
drop if party=="Other"
drop if party=="Independent"
drop if (con==0 & vgd==0 & pty==0 & psi==0 & psp==0)
drop end_marlee end_ideo_marlee


* Dependent variables

gen marlee = ctr_marlee
replace marlee = vgd_marlee if vgd==1
replace marlee = pty_marlee if pty==1
replace marlee = psi_marlee if psi==1
replace marlee = psp_marlee if psp==1

gen vote_marlee = 0
replace vote_marlee = 1 if marlee==1
replace vote_marlee = . if marlee==3

gen vote_leemar = 1
replace vote_leemar = 0 if marlee==1
replace vote_leemar = . if marlee==3


* Treatment-Ideology interactins

gen con_D1 = con * d1
gen vgd_D1 = vgd * d1
gen pty_D1 = pty * d1
gen psi_D1 = psi * d1
gen psp_D1 = psp * d1

gen all_info_D1 = all_info * d1


set more off

*log using "...\1805 Roadmaps\Table A7.log", replace

set seed Xd4e7cf4546c069fbfcba0e1d6cb9da9400043772

probit vote_leemar ///
     con con_D1 ///
     vgd vgd_D1 ///
     pty pty_D1 ///
     psi psi_D1 ///
     psp psp_D1 ///
     , noconstant

tabstat d1 if e(sample), s(n mean sd min p25 p50 p75 max)


estsimp probit vote_leemar ///
     con con_D1 ///
     vgd vgd_D1 ///
     pty pty_D1 ///
     psi psi_D1 ///
     psp psp_D1 ///
     , noconstant


setx median
setx con 1
setx con_D1 .325
simqi, pr listx

simqi, fd(prval(1) genpr(fd_con)) changex(con_D1 -.141 .895)


setx con_D1 0
simqi, pr listx

simqi, fd(prval(1) genpr(tr_pty_con)) changex(con 1 0 pty 0 1)
simqi, fd(prval(1) genpr(tr_vgd_con)) changex(con 1 0 vgd 0 1)
simqi, fd(prval(1) genpr(tr_psi_con)) changex(con 1 0 psi 0 1)
simqi, fd(prval(1) genpr(tr_psp_con)) changex(con 1 0 psp 0 1)


setx median
setx vgd 1
setx vgd_D1 .325
simqi, pr listx

simqi, fd(prval(1) genpr(fd_vgd)) changex(vgd_D1 -.141 .895)


setx vgd_D1 0
simqi, pr listx

simqi, fd(prval(1) genpr(tr_pty_vgd)) changex(vgd 1 0 pty 0 1)
simqi, fd(prval(1) genpr(tr_psi_vgd)) changex(vgd 1 0 psi 0 1)
simqi, fd(prval(1) genpr(tr_psp_vgd)) changex(vgd 1 0 psp 0 1)


setx median
setx pty 1
setx pty_D1 .325
simqi, pr listx

simqi, fd(prval(1) genpr(fd_pty)) changex(pty_D1 -.141 .895)


setx pty_D1 0
simqi, pr listx


setx median
setx psi 1
setx psi_D1 .325
simqi, pr listx

simqi, fd(prval(1) genpr(fd_psi)) changex(psi_D1 -.141 .895)


setx psi_D1 0
simqi, pr listx


setx median
setx psp 1
setx psp_D1 .325
simqi, pr listx

simqi, fd(prval(1) genpr(fd_psp)) changex(psp_D1 -.141 .895)


setx psp_D1 0
simqi, pr listx


* Difference in baseline probabilities

tabstat tr_vgd_con, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat tr_pty_con, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat tr_psi_con, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat tr_psp_con, s(mean sd min p5 p10 p50 p90 p95 max)


tabstat tr_pty_vgd, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat tr_psi_vgd, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat tr_psp_vgd, s(mean sd min p5 p10 p50 p90 p95 max)


* Calculate difference in first differences

gen dif_vgd_con = fd_vgd - fd_con
gen dif_pty_con = fd_pty - fd_con
gen dif_psi_con = fd_psi - fd_con
gen dif_psp_con = fd_psp - fd_con

tabstat dif_vgd_con, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat dif_pty_con, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat dif_psi_con, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat dif_psp_con, s(mean sd min p5 p10 p50 p90 p95 max)


gen dif_pty_vgd = fd_pty - fd_vgd
gen dif_psi_vgd = fd_psi - fd_vgd
gen dif_psp_vgd = fd_psp - fd_vgd

tabstat dif_pty_vgd, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat dif_psi_vgd, s(mean sd min p5 p10 p50 p90 p95 max)
tabstat dif_psp_vgd, s(mean sd min p5 p10 p50 p90 p95 max)


drop b1-b10
drop fd_con-dif_psp_vgd

*log close


set more off

*log using "...\1805 Roadmaps\Table A7 any info.log", replace

set seed Xe073ad5510e51e1e8c4205bdf74dbbc10004419d


probit vote_leemar ///
     con con_D1 ///
     all_info all_info_D1 ///
     , noconstant

tabstat d1 if e(sample), s(n mean sd min p25 p50 p75 max)


estsimp probit vote_leemar ///
     con con_D1 ///
     all_info all_info_D1 ///
     , noconstant


setx median
setx con 1
setx con_D1 .325
setx all_info 0
setx all_info_D1 0
simqi, pr listx

simqi, fd(prval(1) genpr(fd_con)) changex(con_D1 -.141 .895)


setx con_D1 0
simqi, pr listx

simqi, fd(prval(1) genpr(tr_all_info_con)) changex(con 1 0 all_info 0 1)


setx median
setx con 0
setx con_D1 0
setx all_info 1
setx all_info_D1 .325
simqi, pr listx

simqi, fd(prval(1) genpr(fd_all_info)) changex(all_info_D1 -.141 .895)


setx all_info_D1 0
simqi, pr listx


* Difference in baseline probabilities

tabstat tr_all_info_con, s(mean sd min p5 p10 p50 p90 p95 max)


* Calculate difference in first differences

gen dif_all_info_con = fd_all_info - fd_con

tabstat dif_all_info_con, s(mean sd min p5 p10 p50 p90 p95 max)


drop b1-b4
drop fd_con-dif_all_info_con

*log close

* End
